import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import util from '@/common/util.js';


export default {
  name: 'personalInformation',
  components: {},
  data () {
    return {
      id: '',
      siteId: '',
      studentId: '',
      content: ''
    }
  },
  mounted () {
    var _this = this
    _this.siteId = window.sessionStorage.getItem('siteId')
    _this.studentId = window.sessionStorage.getItem('studentId')
    _this.id = _this.$route.query.id
    console.log(_this.siteId, _this.studentId)
    let params = '?siteId=' + _this.siteId + '&studentId=' + _this.studentId;
    http.get(CONSTANT.STUDENTVIEW + params, {
      siteId: _this.siteId,
      studentId: _this.studentId,
      id: _this.id
    }, (res) => {
      console.log(res)
      _this.content = res
    })
    _this.loadList()
  },
  methods: {
    loadList() {
      let _this = this
      http.post(CONSTANT.LEAVEFORM, {
        userId: window.sessionStorage.getItem('studentId'),
        orgId: _this.siteId,
        id: _this.id
      }, (res) => {
        console.log(res)
        _this.content = res.teachLeave
        let dateStr = util.dateFormat(_this.content.createdDate,true)
        _this.content.createdDate = dateStr.substring(0,10)
        if (_this.content.status == '2') {
          _this.content.status = '审核中'
        } else if (_this.content.status == '1') {
          _this.content.status = '通过'
        }
      })
    },
    goQd () {
      let _this = this
      alert(_this.id)
      http.post(CONSTANT.TEACHERSIGN, {
        userId: window.sessionStorage.getItem('studentId'),
        orgId: _this.siteId,
        seq: _this.content.seqs,
        clazzId: _this.id,
        status: 1
      }, (res) => {
          alert(JSON.stringify(res))
      })
    },
    goQj () {
      this.$router.push({path: '/modifyInformation'})
    },
    comeBack () {
      window.history.go(-1)
    },
    qjDelete() {
        let _this = this
        http.post(CONSTANT.LEAVEDELETE, {
          id: _this.id,
          orgId: _this.siteId
        }, (res) => {
          if (res.msg) {
            alert(res.msg)
          } else {
            alert(res)
          }
          _this.$router.push({path: '/qj_list'})
      })
    }
  }
}
